#include<iostream>
#include<vector>
using namespace std;

class Solution
{
public:
    vector<int> searchRange(vector<int>& nums, int target)
    {
        vector<int> res;
        int right = nums.size() - 1;
        int left = 0;

        while (left < right)
        {
            int mid = left + (right - left) / 2;

            if (nums[mid] < target)
            {
                left = mid + 1;
            }
            else
            {
                right = mid;
            }
        }

        if (nums[right] == target)
        {
            res.push_back(nums[right]);
        }
        else
        {
            res.push_back(-1);
        }

        left = 0;
        right = nums.size() - 1;
        while (left < right)
        {
            int mid = left + (right - left + 1) / 2;
            if (nums[mid] > target)
            {
                right = mid - 1;
            }
            else
            {
                left = mid;
            }
        }

        if (nums[right] == target)
        {
            res.push_back(nums[right]);
        }
        else
        {
            res.push_back(-1);
        }
        return res;
    }
};

int main()
{
    Solution s1;

    vector<int> v{ 5,7,7,8,8,10 };
    s1.searchRange(v,8);
    return 0;
}